<?php
namespace SinoPHP\BbdBoss\Model;

use Upfor\UpforPHP\Model;


/**
*解析关系
*/

class  Resolve extends  Model{

    /*
     *初始化操作
     * */

    public function __construct() {
        parent::__construct();
    }

    /**
     * 返回客户域名相关信息
     * $param int $id
     * @return array $resolveClientDomainArray
     */

    public function  resolveClientDomain($id){
         $this->setTableName('customer_domain');
         $map['domain_id']=intval($id);
         $map['domain_status'] =2;
         $domainTypeStatus=0;
         $field ='domain_id as inner_domain_id,domain_cname,domain_name,domain_source_name as domain_suffix_name';
         $resolveClientDomainArray= $this->getList($field,$map);
          if(is_array($resolveClientDomainArray) && !empty($resolveClientDomainArray)) {
              foreach ($resolveClientDomainArray as $key => $val) {
                       $resolveClientDomainArray[$key]['inner_domain_id'] = $domainTypeStatus.':'.$val['inner_domain_id'];
              }
          }else{
              $resolveClientDomainArray='';
          }
         return $resolveClientDomainArray;
    }

    /**
     * 查询当前客户域名是否存在
     * $param int $id
     * $return array $getRow
     */

    public function getCustomerDomain($id){
        $this->setTableName('customer_domain');
        $map['domain_id']=intval($id);
        $map['domain_status'] =2;
        $field='domain_id as inner_domain_id,domain_source_name,domain_name,domain_cname';
        $getRow = $this->getRow($field,$map);
        return $getRow;
    }

}
